import bcc
import simplejson as json

from google.appengine.ext import webapp
from google.appengine.ext.webapp import util

class Compiler(webapp.RequestHandler):
  parser = bcc.Parser()

  def post(self):
    source = self.request.get('source')
    pages = self.parser.Parse(source)
    self.response.out.write(json.dumps({'pages': pages}))

application = webapp.WSGIApplication([
  ('/compile', Compiler),
  ], debug=True)

def main():
  util.run_wsgi_app(application)

if __name__ == '__main__':
  main()
